package com.gagakuai.demo.beanFactoryPostProccess;

import org.springframework.beans.BeansException;
import org.springframework.beans.factory.config.BeanDefinition;
import org.springframework.beans.factory.config.ConfigurableListableBeanFactory;
import org.springframework.beans.factory.support.BeanDefinitionBuilder;
import org.springframework.beans.factory.support.BeanDefinitionRegistry;
import org.springframework.beans.factory.support.BeanDefinitionRegistryPostProcessor;
import org.springframework.stereotype.Component;

/*
 * @program: settement
 * @description:
 * @author: houhong
 * @create: 2022-11-12 16:12
 */
@Component
public class MyBeanFctoryDefinitionPostProcessor implements BeanDefinitionRegistryPostProcessor {

    @Override
    public void postProcessBeanDefinitionRegistry(BeanDefinitionRegistry registry) throws BeansException {

        BeanDefinition beanDefinitionBuilder = BeanDefinitionBuilder.genericBeanDefinition(Service2.class)
                .getBeanDefinition();
        registry.registerBeanDefinition("houhong",beanDefinitionBuilder);
    }

    @Override
    public void postProcessBeanFactory(ConfigurableListableBeanFactory beanFactory) throws BeansException {

    }
}